package com.d0326;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class TestHashMap {
    public static void main(String[] args) {
        Map<String,Student> studentMap = new HashMap<>();
        Student s1 = new Student("jack",20,98);
        Student s2 = new Student("jack1",22,98);
        Student s3 = new Student("jack2",21,98);
        studentMap.put("j",s1);
        studentMap.put("a",s2);
        studentMap.put("c",s3);
        studentMap.put("k",s1);

        /*System.out.println(studentMap.size());

        Student x1 = studentMap.get("a");
        System.out.println(x1);*/

        Set<String> keys = studentMap.keySet();
        for (String str :
                keys) {
            System.out.println(str+"------->"+studentMap.get(str));
        }

        Collection<Student> values = studentMap.values();
        for (Student stu :
                values) {
            System.out.println(stu);
        }

        Set<Map.Entry<String,Student>> entrys = studentMap.entrySet();
        for (Map.Entry entry :
                entrys) {
            System.out.println(entry.getKey()+"----->"+entry.getValue());
        }

        studentMap.forEach((K,V)->
                System.out.println(K+"----->"+V));
    }
}
